<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /* 
        录入学生信息，其中包括姓名，性别，年龄，身高，将其放进同一个数组中，并对数组以身高从高到低进行排序。
                           */
        var students = [];
        function student(name, sex, age, high) {
            let obj = new Object();
            obj.name = name;
            obj.sex = sex;
            obj.age = age;
            obj.high = high;
            return obj;
        }
        function join() {
            let sName = prompt('请输入姓名');
            let sSex = prompt('请输入性别');
            let sAge = prompt('请输入年龄');
            let sHigh = prompt('请输入身高');
            let stu = student(sName, sSex, sAge, sHigh);
            students.push(stu);
            let isGoon = confirm('是否继续？');
            if (isGoon) {
                join();
            } else {
                sortArr();
            }
        }
        function sortArr() {
            students.sort(function (a, b) {
                return (a.high - b.high)
            });
        }
        join();
        console.log(students);
    </script>
</body>

</html>